package com.yiji.fintech.musfinance.common.handler;

import com.acooly.core.utils.Collections3;
import com.google.common.collect.Maps;
import com.yiji.fintech.musfinance.common.service.OpratorService;
import com.yiji.fintech.musfinance.common.domain.base.BaseDomain;
import com.yiji.fintech.musfinance.common.exception.UniqueCheckException;
import com.yiji.fintech.musfinance.common.handler.base.BaseHandler;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 唯一性校验
 * Created by ouwen@yiji.com} on 2017/9/18.
 */
@Service
public class UniqueServiceHandler extends OpratorService implements BaseHandler {
    @Override
    public void doExcute(BaseDomain domain) {
        initDbService(domain);
        Map<String,Object> params = Maps.newHashMap();
        params.put("EQ_bizOrderNo",domain.getBizOrderNo());
        Map<String, Boolean> sortMap = Maps.newHashMap();
        List datas = service.query(params,sortMap);
        if(Collections3.isNotEmpty(datas)){
            throw new UniqueCheckException("订单唯一性校验不通过流水【"+domain.getBizOrderNo()+"】存在");
        }
    }
}
